package org.codetranslators.tools.visualization;

import java.awt.Container;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JToolBar;
import javax.swing.UIManager;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Toolkit;

public class GraphViewer extends JFrame{
	
	private MainPanel mainPanel;

	public static void main(String[] args){
		GraphViewer graphViewer = new GraphViewer();
		graphViewer.initialize();
	}

	public GraphViewer(){
		
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (Exception e) {}
		
		mainPanel = new MainPanel();
		Container container = getContentPane();
		container.add(mainPanel);
		
	}
	
	public void initialize(){
		
		setTitle("Graph View Utility");
		pack();

        int width = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth();
        int height = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();
        
        Dimension size = new Dimension(width, height - 50);
        
        setSize(size);
        
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
        
        Container container = getContentPane();
        GraphViewerToolBar graphViewerToolBar = new GraphViewerToolBar();
		container.add(graphViewerToolBar, BorderLayout.NORTH);

	}  	
}

class GraphViewerToolBar extends JToolBar
{
	public GraphViewerToolBar()
	{		
		JButton newButton = new JButton(new ImageIcon("resources/images/new.jpg"));
		JButton printButton = new JButton(new ImageIcon("resources/images/print.jpg"));
		JButton findButton = new JButton(new ImageIcon("resources/images/find.jpg"));
		JButton cutButton = new JButton(new ImageIcon("resources/images/cut.jpg"));
		JButton copyButton = new JButton(new ImageIcon("resources/images/copy.jpg"));
		JButton pasteButton = new JButton(new ImageIcon("resources/images/paste.jpg"));
		JButton undoButton = new JButton(new ImageIcon("resources/images/undo.jpg"));
		JButton cfgViewButton = new JButton(new ImageIcon("resources/images/cfg.jpg"));
		
		Insets margins = new Insets(0, 0, 0, 0);
		newButton.setMargin(margins);
		
		add(newButton);
		add(printButton);
		add(findButton);
		add(cutButton);
		add(copyButton);
		add(pasteButton);
		add(undoButton);
		add(cfgViewButton);
		
	}
}
